﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Communergy.Common;

namespace CurrentCostLibrary
{
    public static class CurrentCostHelpers
    {
        public static EnergyMonitorSensorType GetSensorType(int sensorTypeValue)
        {
            try
            {
                var thisType = (EnergyMonitorSensorType)Enum.ToObject(typeof(EnergyMonitorSensorType), sensorTypeValue);

                if (thisType.IsDefined())
                {
                    return thisType;
                }
                else
                {
                    return EnergyMonitorSensorType.None;
                }

            }
            catch
            {
                return EnergyMonitorSensorType.None;
            }
        }


        public static bool IsDefined(this System.Enum value)
        {
            return System.Enum.IsDefined(value.GetType(), value);
        }
    }
}
